package com.openbravo.pos.printer.escpos;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public abstract class PrinterWritter
{
  private boolean initialized = false;
  private ExecutorService exec = Executors.newSingleThreadExecutor();

  protected abstract void internalWrite(byte[] paramArrayOfByte);

  protected abstract void internalFlush();

  protected abstract void internalClose();

  public void init(byte[] paramArrayOfByte)
  {
    if (!this.initialized)
    {
      write(paramArrayOfByte);
      this.initialized = true;
    }
  }

  public void write(String paramString)
  {
    write(paramString.getBytes());
  }

  public void write(final byte[] paramArrayOfByte)
  {
    this.exec.execute(new Runnable()
    {
      public void run()
      {
        PrinterWritter.this.internalWrite(paramArrayOfByte);
      }
    });
  }
  
//	public void write(final byte data[]) {
//		exec.execute(new Runnable() {
//
//			final byte val$data[];
//			final PrinterWritter this$0;
//
//			public void run() {
//				internalWrite(data);
//			}
// 
//		});
//	}
//  
  

  public void flush()
  {
    this.exec.execute(new Runnable()
    {
      public void run()
      {
        PrinterWritter.this.internalFlush();
      }
    });
  }

  public void close()
  {
    this.exec.execute(new Runnable()
    {
      public void run()
      {
        PrinterWritter.this.internalClose();
      }
    });
    this.exec.shutdown();
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.printer.escpos.PrinterWritter
 * JD-Core Version:    0.6.0
 */